package com.gem.day06.extend2;

/**矩形子类*/
public class Rect extends Shape {
	//特有属性
	private int l;
	private int w;

	public Rect() {

	}

	public Rect(int l, int w) {
		//调用父类空参构造方法
		//注意:此处无论是否写super(),都会调用父类构造方法
		//原理:创建子类对象时会优先创建父类对象
		//super();
		this.l = l;
		this.w = w;
		System.out.println("Rect.Rect()");
	}

	public int getL() {
		return l;
	}

	public void setL(int l) {
		this.l = l;
	}

	public int getW() {
		return w;
	}

	public void setW(int w) {
		this.w = w;
	}

	@Override
	public double length() {
		return 2 * (l + w);
	}

	@Override
	public double area() {
		return l * w;
	}

	@Override
	public String toString() {
		return "Rect [l=" + l + ", w=" + w + "]";
	}
}
